<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>打印图形</title>
	</head>
	<body>
		<!--三角形-->
		<!--219970909黄世萍-->
		<script>
			var num=prompt("请输入三角形打印的行数: ")
			var str=''
			 for (var i=1 ;  i<=num;  i++)//定义变量i
			{
				for( var j=1; j<=num-i; j++)//利用for循环打印
				{
					document.write("&ensp;");//&ensp打印空格
				}
				for( var k=1; k<=i ; k++)
				{
					
					document.write("* &ensp;");
				}
				document.write("<br>")//在页面输出字符串
		   }
			</script>

		<!--打印平行四边形-->
			<script>
			var  num=prompt("请输入平行四边形打印的行数: ") 
			
		    for (var a=1 ;a<=num ;a++)
			{
				for (c=a; c<=num; c++)
				{
					document.write(" &ensp;");
				}
				
		        for ( b=1; b<=num; b++)
				{
					document.write(" "+ "*&ensp;" );
				}
				document.write("<br>")
			}
		</script>
		<!--打印菱形-->
		<script>
			
		var num=prompt("请输入打印菱形的行数:");
			
		if(num%2==0)
		{
			num++;
		}
	    for (var  i = 0; i < num/2; i++) 
		{
			for (var j = num/2; j > i; j--) 
			{
				document.writeln("&nbsp");
			}
			for (var k = 0; k < 2 * i + 1; k++) 
			{
				document.writeln("* ");
			}
			document.write("</br>");
		}
	    for (var i = (num/2)-1; i > 0; i--) 
		{
			for (var j = num/2; j >= i; j--) 
			{
				document.writeln("&nbsp");
			}
			for (var k = 0; k < i*2; k++)
			{
				document.writeln("* ");
			}
			document.write("</br>")
		}
		</script>
	</body>
</html>